<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%-- 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>File </title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<%@ include file="/dwz/dwz_inc.jsp" %>
<base href="<%=basePath%>">
<script type="text/javascript">
	
	$(function(){
	
	$(".timelong").each(function(){
		$(this).html( new Date(parseInt($(this).html())).formatDate("yyyy-MM-dd HH:mm:ss") );
	});
	
	DWZ.init("dwz/dwz.frag.xml", {
		statusCode:{ok:200, error:300, timeout:301}, //【可选】
		pageInfo:{pageNum:"pageNum", numPerPage:"numPerPage", orderField:"orderField", orderDirection:"orderDirection"}, //【可选】
		debug:false,	// 调试模式 【true|false】
		callback:function(){
			initEnv();
			$("#themeList").theme({themeBase:"dwz/themes"}); // themeBase 相对于index页面的主题base路径
		}
	});
});
	
</script>
</head>

<body>
 --%>
<form action="admin/file!list" method="post" onsubmit=" return navTabSearch(this)">

		<div class="panelBar">
			<ul class="toolBar">
				
				<li>
					文件夹:<input type="text"  class="textbox" name="folder"
						value="${ folder }" size="8" maxlength="20" />
					文件名:<input type="text"  class="textbox" name="name"
						value="${name[0] }" size="8" maxlength="20" />
				</li>
				<li>
					<div class="buttonActive">
						<div class="buttonContent">
							<button type="submit" >搜索</button>
						</div>
					</div>
				</li>
				
				<li class=""><a target="dialog"
					href="admin/file!upload?folder=${folder}" ref="file_add"
					class="add" height="340"><span>上传</span> </a>
				</li>
				
				<li><a title="确定要删除吗?" target="selectedTodo" rel="ids"
					href="admin/file!delete" class="delete"> <span>删除</span> </a>
				</li>

			</ul>
		</div>
</form>

<s:if test="!root">
<div class="panelBar">
	<a class="button" target="navTab" rel="file_list"  href="admin/file!list?folder=${ folder }/../" ><span>向上</span></a>
		
</div>
</s:if>

<div class="gridScroller" style=" overflow: auto;"
			>
			<TABLE class="table" width="100%" border=1
				align="center" height="28px" layoutH="120">
				<thead>
					<TR >						
						<Th>文件名</Th>
						<Th>Size</Th>
						<Th>修改时间</Th>
						<Th>类型</Th>
						<Th>操作</Th>
					</TR>
				</thead>
				<TBODY>
		<s:iterator value="files" var="data">
		<tr target="sid_user" ref="${data.name }">
		
			<td valign="middle" >
				<s:if test="#data.directory">
					<a target="navTab" rel="file_list" href="admin/file!list?folder=${ folder}/${data.name}"
					path="${ folder}/${data.name}"
					>
					<img src="images/folder.png" style="width:22px;height:22px;" align="absmiddle"></img>
						${data.name }
					</a>
				</s:if>
				<s:else>
					<a target="_blank"  width="800" height=600 title="${data.name}" fname='${name }'
					folder="${folder }" name="fpath"
					>
				<img src="admin/file!icon?name=${data.name}&folder=${ folder}" style="width:22px;height:22px;" align="absmiddle"></img>
						${data.name }
					</a>
				</s:else>
				
			</td>
			<td  align="center" class="filesize">${data.size }</td>
			<td align="center" class="timelong">${ data.time} </td>
			<td align="center">${data.directory ? "文件夹" : "文件"}</td>

			<td valign="middle" align="center">
				<div>
					<a class="btnEdit" width="800" height=600
						rel="file_edit_${data.sn }"
						href="admin/file!edit?name=${data.name}&folder=${ folder}"
						target="navTab" external=true title="编辑${ folder}/${data.name}"><span>编辑${ folder}/${data.name}</span></a>
					 <a class="btnDel" rel="file_list"
						href="admin/file!delete?name=${data.name}&folder=${folder}" target="ajaxTodo"
						title="删除">删除</a>
				</div>
			</td>
			
		</tr>
		</s:iterator>
		<s:if test="files.size==0">
			<tr>
				<td align="center">空</td>
			</tr>		
		</s:if>

	</TBODY>
			</TABLE>
			</div>
			<script type="text/javascript">
	
	$(".timelong").each(function(){
		$(this).html( new Date(parseInt($(this).html())).formatDate("yyyy-MM-dd HH:mm:ss") );
		
		
	});
	$(".filesize").each(function(){
		try{
			var longsize=parseInt($(this).html());
			if(longsize<1024) {
				$(this).html(longsize + "&nbsp;B");		
			} else if(longsize<1024*1024) {
				$(this).html( Math.ceil(10*longsize/1024)/10 + "&nbsp;KB");
			} else if(longsize<1024*1024*1024) {
				$(this).html(Math.ceil(10*longsize/(1024*1024))/10 + "&nbsp;MB");
			}
		}catch(e){}
	});
	
	$("a[name='fpath']").each(function(){
		var f = $(this).attr("folder") + "/";
		var n = $(this).attr("fname");
		var p="";
		if(f && n){
		  f= f.replace(/^\/+/,"");
		  p = f + n;
		}
		$(this).attr("href",escape(p));
	});
	
	$("a[rel='file_name']").each(function(){
		var href = 	escape($(this).attr('href'));
		$(this).attr('href',href);
		
	});

</script>
<!-- </body>
</html> -->

